﻿using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.Entity;
using System.Data.Entity.Config;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Migrations;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Loans.Domain.Model;

namespace Loans.Domain
{
//   public static class Helper
//   {
//       public static string GetConnectionString()
//       {
//        
//           SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
//           builder.DataSource = @".\sqlexpress";
//           builder.InitialCatalog = "migrateme";
//           builder.IntegratedSecurity = true;
//           builder.MultipleActiveResultSets = true;
//           return builder.ConnectionString;
//       }
//   }
    /// <summary>
    /// </summary>
    public class LoansDb : DbContext, ILoansDb
    {
        //     public LoansDb() :base()
  //     {
  //        //DbConfiguration.SetConfiguration( new LoansDbConfig());
  //        DbMigrator dbMigrator = new DbMigrator(new DbMigrationsConfiguration<LoansDb>());
  //        dbMigrator.Configuration.TargetDatabase = new DbConnectionInfo(ConStr);
  //        dbMigrator.Configuration.AutomaticMigrationsEnabled = true;
  //        dbMigrator.Update();
  //     }

 //       protected static string ConStr { get; set; }
 //
       public LoansDb(string nameOrConnectionString) : base(nameOrConnectionString)
       {
       //     ConStr = nameOrConnectionString;
       }


        public DbSet<User> Users { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<Profile> Profiles { get; set; }


        IQueryable<Profile> ILoansDb.Profiles
        {
            get { return Profiles; }
        }


        IQueryable<User> ILoansDb.Users
        {
            get { return Users; }
        }

        IQueryable<Role> ILoansDb.Roles
        {
            get { return Roles; }
        }
    }
}
